1 #include "Processbar.h"
2 #include <unistd.h>
3
4 double bandwidth = 1024 * 1024 * 1.0;
5
6 void download(double filesize, callback_t cb)
7 {
	8   double current = 0.0;
	9
		10   printf("download begin,current:%lf\n", current);
	11   while (current <= filesize)
		12   {
		13     cb(filesize, current);
		14     usleep(100000);
		15     current += bandwidth;
		16
			17   }
	18   printf("\ndownload done,filesize:%lf\n", filesize);
	19
		20 }
21
22 int main()
23 {
	24   download(100 * 1024 * 1024, ProcBar);
	25   download(2 * 1024 * 1024, ProcBar);
	26   return 0;
	27 }
